<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model.lazy.trim="obj.name"><br><br>

      <label>年龄：</label>
      <input type="number" v-model.lazy.trim="obj.age"><br><br>

      <label>身高：</label>
      <input type="number" v-model.lazy.trim="obj.stature">(米)<br><br>

      <label>体重：</label>
      <input type="number" v-model.lazy.trim="obj.weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model.lazy.trim="obj.history"><br><br>

      <button @click.prevent="zhen">诊断</button>
    </form>

    <p v-show="fool">患者 {{obj.name}} 的诊断结果：{{obj.weight}}</p>
  </div>
</template>

<script>
export default {
  data(){
    return {
      obj:{
        name:"",
        age:"",
        stature:"",
        weight:"",
        history:"",
      },
      Bim:"",
      fool:false,
    }
  },
  methods:{
    zhen(){
         this.Bim=this.obj.weight/(this.obj.stature*this.obj.stature)
        if(!this.Bim)return 
        if(!this.obj.name)return 
        if(!this.obj.age)return 
        if(!this.obj.stature)return 
        if(!this.obj.weight)return 
        if(!this.obj.history)return 
        if(this.Bim<18.5) {
          this.obj.weight="体重过轻"
           this.fool=true
         }else if(this.Bim>=18.5&&this.Bim<24.9){
          this.obj.weight="正常"
           this.fool=true
         }else if(this.Bim>=24.9&&this.Bim<29.9){
          this.obj.weight="体重过重"
           this.fool=true
         }else {         
          this.obj.weight="要减肥了"
          this.fool=true
         }
    }
  }
}
</script>